Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Aug 5, 2025

Link issues

fixes #6550

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Introduce a new service method to obtain the client hub connection ID in the browser, integrate it in the default service implementation and JS modules, and update the sample UI and localization to support this feature.

New Features:

  • Add GetClientHubIdAsync to IBrowserFingerService with JS integration to retrieve the client hub connection ID

Enhancements:

  • Implement getClientHubId function in the JS utility module and adjust the fallback logic in client.js
  • Update the BrowserFingers sample component to fetch and display the client hub ID and set inputs to read-only
  • Add localization entries for the new GetClientHubIdAsync method

@bb-auto bb-auto bot added the enhancement New feature or request label Aug 5, 2025
@bb-auto bb-auto bot added this to the 9.9.0 milestone Aug 5, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 5, 2025

Reviewer's Guide

This PR introduces a new GetClientHubIdAsync method across the BrowserFinger service, implements it in the default service and JS utility module, and updates the sample component to fetch and display the client hub connection ID, along with minor UI and fallback operator tweaks.

Sequence diagram for GetClientHubIdAsync flow in BrowserFingers component

sequenceDiagram
    participant BrowserFingers as BrowserFingers Component
    participant BrowserFingerService as IBrowserFingerService
    participant DefaultBrowserFingerService
    participant JSModule
    participant JSUtility as utility.js

    BrowserFingers->>BrowserFingerService: GetClientHubIdAsync()
    BrowserFingerService->>DefaultBrowserFingerService: GetClientHubIdAsync()
    DefaultBrowserFingerService->>JSModule: LoadUtility()
    JSModule->>JSUtility: getClientHubId()
    JSUtility-->>JSModule: clientHubId (from localStorage)
    JSModule-->>DefaultBrowserFingerService: clientHubId
    DefaultBrowserFingerService-->>BrowserFingerService: clientHubId
    BrowserFingerService-->>BrowserFingers: clientHubId
Loading

Class diagram for IBrowserFingerService and DefaultBrowserFingerService changes

classDiagram
    class IBrowserFingerService {
        +Task<string?> GetFingerCodeAsync(CancellationToken token = default)
        +Task<string?> GetClientHubIdAsync(CancellationToken token = default)
    }
    class DefaultBrowserFingerService {
        +Task<string?> GetFingerCodeAsync(CancellationToken token = default)
        +Task<string?> GetClientHubIdAsync(CancellationToken token = default)
    }
    IBrowserFingerService <|.. DefaultBrowserFingerService
Loading

File-Level Changes

Change Details Files
Extend IBrowserFingerService with GetClientHubIdAsync and implement it
  • Add GetClientHubIdAsync signature to service interface
  • Implement GetClientHubIdAsync in DefaultBrowserFingerService invoking JS module
IBrowserFingerService.cs
DefaultBrowserFingerService.cs
Add getClientHubId JS utility function
  • Export getClientHubId reading from localStorage
utility.js
Adjust client.js fallback logic for connection ID
  • Replace null-coalescing operator (??) with logical OR (
Update BrowserFingers sample to fetch and display client hub ID
  • Add _clientHubId field and invoke GetClientHubIdAsync in OnInitializedAsync
  • Define GetClientHubIdAsync wrapper method
  • Update Razor UI to use Value/Readonly and include new input for client hub ID
  • Add GetClientHubIdAsync metadata to method list
BrowserFingers.razor.cs
BrowserFingers.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#6550 Add a GetClientHubIdAsync method to the IBrowserFingerService interface.
#6550 Implement the GetClientHubIdAsync method in the DefaultBrowserFingerService class to retrieve the client hub ID.
#6550 Expose and demonstrate the GetClientHubIdAsync method in the BrowserFingers sample component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Aug 5, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

  • You added Localizer keys for GetClientHubIdAsync and a new DisplayText for ClientHubId but didn’t update en-US.json or zh-CN.json with those entries—please add the corresponding localization strings.
  • The getClientHubId JS function returns only localStorage.getItem('bb_hub_connection_id') without fallback; consider mirroring getClientInfo’s fallback logic or handling nulls so you don’t end up with an unexpected null.
  • OnInitializedAsync awaits the two service calls sequentially; you could run GetFingerCodeAsync and GetClientHubIdAsync in parallel (e.g. via Task.WhenAll) to improve load performance.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You added Localizer keys for GetClientHubIdAsync and a new DisplayText for ClientHubId but didn’t update en-US.json or zh-CN.json with those entries—please add the corresponding localization strings.
- The getClientHubId JS function returns only localStorage.getItem('bb_hub_connection_id') without fallback; consider mirroring getClientInfo’s fallback logic or handling nulls so you don’t end up with an unexpected null.
- OnInitializedAsync awaits the two service calls sequentially; you could run GetFingerCodeAsync and GetClientHubIdAsync in parallel (e.g. via Task.WhenAll) to improve load performance.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/wwwroot/modules/client.js:27` </location>
<code_context>
     if (result) {
         data.ip = result.Ip;
     }
-    data.id = localStorage.getItem('bb_hub_connection_id') ?? result.Id;
+    data.id = localStorage.getItem('bb_hub_connection_id') || result.Id;
     return data;
 }
</code_context>

<issue_to_address>
Switching from nullish coalescing (??) to logical OR (||) may cause unintended behavior if the stored value is an empty string.

'||' treats empty strings as falsy, so if 'bb_hub_connection_id' is '', it will default to 'result.Id'. Use '??' if you only want to fall back when the value is null or undefined.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang merged commit 582eebd into main Aug 5, 2025
4 checks passed
@ArgoZhang ArgoZhang deleted the refactor-finger branch August 5, 2025 02:33
@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.93%. Comparing base (09e200c) to head (50f008e).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main    #6551      +/-   ##
===========================================
- Coverage   100.00%   99.93%   -0.07%     
===========================================
  Files          714      715       +1     
  Lines        31397    31471      +74     
  Branches      4432     4444      +12     
===========================================
+ Hits         31397    31451      +54     
- Misses           0       15      +15     
- Partials         0        5       +5     
Flag Coverage Δ
BB 99.93% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(IBrowserFingerService): add GetClientHubIdAsync method

2 participants